// Code generated by bpf2go; DO NOT EDIT.
//go:build 386 || amd64 || amd64p32 || arm || arm64 || loong64 || mips64le || mips64p32le || mipsle || ppc64le || riscv64

package tracer

import (
	"bytes"
	_ "embed"
	"fmt"
	"io"

	"github.com/cilium/ebpf"
)

type socketEntry struct {
	Daddr  [16]uint8
	Saddr  [16]uint8
	Dport  uint16
	Sport  uint16
	Proto  uint16
	Family uint16
	State  uint8
	_      [7]byte
	Inode  uint64
}

// loadSocket returns the embedded CollectionSpec for socket.
func loadSocket() (*ebpf.CollectionSpec, error) {
	reader := bytes.NewReader(_SocketBytes)
	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
	if err != nil {
		return nil, fmt.Errorf("can't load socket: %w", err)
	}

	return spec, err
}

// loadSocketObjects loads socket and converts it into a struct.
//
// The following types are suitable as obj argument:
//
//	*socketObjects
//	*socketPrograms
//	*socketMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func loadSocketObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
	spec, err := loadSocket()
	if err != nil {
		return err
	}

	return spec.LoadAndAssign(obj, opts)
}

// socketSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type socketSpecs struct {
	socketProgramSpecs
	socketMapSpecs
}

// socketSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type socketProgramSpecs struct {
	IgSnapTcp *ebpf.ProgramSpec `ebpf:"ig_snap_tcp"`
	IgSnapUdp *ebpf.ProgramSpec `ebpf:"ig_snap_udp"`
}

// socketMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type socketMapSpecs struct {
}

// socketObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to loadSocketObjects or ebpf.CollectionSpec.LoadAndAssign.
type socketObjects struct {
	socketPrograms
	socketMaps
}

func (o *socketObjects) Close() error {
	return _SocketClose(
		&o.socketPrograms,
		&o.socketMaps,
	)
}

// socketMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to loadSocketObjects or ebpf.CollectionSpec.LoadAndAssign.
type socketMaps struct {
}

func (m *socketMaps) Close() error {
	return _SocketClose()
}

// socketPrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to loadSocketObjects or ebpf.CollectionSpec.LoadAndAssign.
type socketPrograms struct {
	IgSnapTcp *ebpf.Program `ebpf:"ig_snap_tcp"`
	IgSnapUdp *ebpf.Program `ebpf:"ig_snap_udp"`
}

func (p *socketPrograms) Close() error {
	return _SocketClose(
		p.IgSnapTcp,
		p.IgSnapUdp,
	)
}

func _SocketClose(closers ...io.Closer) error {
	for _, closer := range closers {
		if err := closer.Close(); err != nil {
			return err
		}
	}
	return nil
}

// Do not access this directly.
//
//go:embed socket_bpfel.o
var _SocketBytes []byte
